package com.cskaoyan.config4;

import com.alibaba.druid.pool.DruidDataSource;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

/**
 * @ConfigurationProperties注解
 * @author stone
 * @date 2022/10/10 16:10
 */
@Configuration
public class DataSourceConfiguration4 {

    @Autowired
    DataSourceProperties4 properties4;

    @Bean
    public DataSource dataSource4() {
        DruidDataSource dataSource = new DruidDataSource();
        // ctrl + alt + v
        dataSource.setDriverClassName(properties4.getDriverClassName());
        dataSource.setUrl(properties4.getUrl());
        dataSource.setUsername(properties4.getUsername());
        dataSource.setPassword(properties4.getPassword());
        return dataSource;
    }
}
